interface State {
	list: any[]
}

const initState: State = {
	list: []
}

const ADD_LIST = 'ADD_LIST'

export const addListCreateAction = (payload: any) => {
	return { type: ADD_LIST, payload }
}

const historyReducer = (state = initState, action: any) => {
	switch(action.type) {
		case ADD_LIST:
			const list = state.list.filter(v => v.id !== action.payload.id)

			return {
				...state,
				list: [action.payload, ...list]
			}
		default :
			return state
	}
}


export default historyReducer